﻿
module("FallingT.init")
test("FallingT init", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    equal(5, fallingT.center.x, "CenterX of FallingT is set");
    equal(6, fallingT.center.y, "CenterY of FallingT is set");

    var relativeBody="";
    for (var i = 0; i < fallingT._relativeBody.length; i++) {
        relativeBody += fallingT._relativeBody[i].coordinate.toString() + " ";
    }
    equal("(-1,0) (0,0) (1,0) (0,1) ", relativeBody, "CenterY of FallingT is set");

    var body= "";
    for (var i = 0; i < fallingT.getBody.length; i++) {
        body += fallingT.getBody[i].coordinate.toString() + " ";
    }
    equal("(4,6) (5,6) (6,6) (5,7) ", body, "CenterY of FallingT is set");  
});

test("FallingT moveTo", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.moveTo(7, 8);

    deepEqual(7, fallingT.center.x, "CenterX of FallingT is set to new x");
    equal(8, fallingT.center.y, "CenterY of FallingT is set to new y");

    var relativeBody = "";
    for (var i = 0; i < fallingT._relativeBody.length; i++) {
        relativeBody += fallingT._relativeBody[i].coordinate.toString() + " ";
    }
    equal("(-1,0) (0,0) (1,0) (0,1) ", relativeBody, "CenterY of FallingT is set");

    var body = "";
    for (var i = 0; i < fallingT.getBody.length; i++) {
        body += fallingT.getBody[i].coordinate.toString() + " ";
    }
    equal("(6,8) (7,8) (8,8) (7,9) ", body, "CenterY of FallingT is set");
});

test("FallingT moveRight", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.moveRight(); 
    deepEqual(6, fallingT.center.x, "CenterX of FallingT is set to x+1");
    equal(8, fallingT.center.y, "CenterY of FallingT is same");
});

test("FallingT moveLeft", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.moveLeft();
    deepEqual(4, fallingT.center.x, "CenterX of FallingT is set to x-1");
    equal(8, fallingT.center.y, "CenterY of FallingT is same");
});

test("FallingT moveUp", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.moveUp();
    equal(5, fallingT.center.x, "CenterX of FallingT is same");
    equal(7, fallingT.center.y, "CenterY of FallingT is set to y-1");
});

test("FallingT moveDown", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.moveDown();
    equal(5, fallingT.center.x, "CenterX of FallingT is same");
    equal(9, fallingT.center.y, "CenterY of FallingT is set to y+1");
});

test("FallingT rotate", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.rotate();
    equal(90, fallingT.rotation, "Rotation of FallingT is set to 90");
});

test("FallingT rotate twice", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.rotate();
    equal(90, fallingT.rotation, "Rotation of FallingT is set to 90");
    fallingT.rotate();
    equal(180, fallingT.rotation, "Rotation of FallingT is set to 180");
});

test("FallingT rotateBack", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.rotateBack();
    equal(270, fallingT.rotation, "Rotation of FallingT is set to 270");   
});

test("FallingT rotateTo", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingT = new tetris.FallingT(x, y, color);
    fallingT.rotateTo(180);
    equal(180, fallingT.rotation, "Rotation of FallingT is set to 180");
});

